package com.oscar.ehome.view.pageview.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.oscar.ehome.R;
import com.oscar.ehome.bean.pagebean.SginTwoMessageBean;
import com.oscar.ehome.bean.setbean.SginchuqinBean;
import com.oscar.ehome.utils.basethem.TintManager;
import com.oscar.ehome.utils.system.SystemConfigFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by juxing
 * author: MengWanhe
 * date: On 2017/10/18
 */

public class SignTwoAdapter extends BaseAdapter {
    private List<SginTwoMessageBean.punchcardRecordListBean> list = new ArrayList<>();

    private LayoutInflater mInflater;
    private Context mContext = null;

    public SignTwoAdapter(Context context, List<SginTwoMessageBean.punchcardRecordListBean> list) {
        this.mContext = context;
        this.list = list;
        mInflater = LayoutInflater.from(context);
    }


    public void setList(List<SginTwoMessageBean.punchcardRecordListBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.adapter_punchcard, null);
            holder = new ViewHolder();
            holder.sgintwo_dao_time = (TextView) convertView.findViewById(R.id.sgintwo_dao_time);
            holder.sgintwo_adrss = (TextView) convertView.findViewById(R.id.sgintwo_adrss);
            holder.sgintwo_adrss_img = (ImageView) convertView.findViewById(R.id.sgintwo_adrss_img);
            convertView.setTag(holder); //
        } else {
            holder = (ViewHolder) convertView.getTag(); //
        }
        if (list.size() > 0) {
            SginTwoMessageBean.punchcardRecordListBean bean = list.get(position);
            if (bean != null) {
                holder.sgintwo_dao_time.setText(bean.getCreateDate());
                holder.sgintwo_adrss.setText(bean.getInfo());
            }
        }
        return convertView;
    }


    class ViewHolder {
        TextView sgintwo_dao_time;//时间
        TextView sgintwo_adrss;//地址
        ImageView sgintwo_adrss_img;
    }
}
